﻿var CSP_TopSearch = {
    Txt_SearchValueId: "",
    Txt_DefaultSearchValueId: "",
    Btn_SearchId: "",
    Init: function () {
        this.SearchEvent();
        $.jqtab = this.TabChange;
        $.jqtab("#tabs2", "#tab_conbox2", "mouseenter");
    },
    SearchClick: function () {
        if ($("#" + this.Txt_SearchValueId).val() == "") {
            $("#" + this.Txt_SearchValueId).val($("#" + this.Txt_DefaultSearchValueId).val());
        }
        window.location.href = "/search/?SearchValue=" + encodeURI($("#" + this.Txt_SearchValueId).val());
    },
    TabChange: function (tabtit, tab_conbox, shijian) {   //切换标签
        $(tabtit).find("li:first").addClass("item current").show();
        $(tab_conbox).find("li:first").show();

        $(tabtit).find("li").bind(shijian, function () {
            $(this).addClass("item current").siblings("li").removeClass("current");
            var activeindex = $(tabtit).find("li").index(this);
            $(tab_conbox).children().eq(activeindex).show().siblings().hide();
            return false;
        });
    },
    SearchEvent: function () {       //搜索事件
        $("#" + this.Txt_SearchValueId).bind("keydown", function (e) {
            if (e.which == 13) {
                $("#" + this.Btn_SearchId).click();
            }
        });
        document.getElementsByTagName('form')[0].onkeydown = function (e) {
            var e = e || event;
            var keyNum = e.which || e.keyCode;
            return keyNum == 13 ? false : true;
        };
    }
}